<?php

include_once  'define.php';
include_once  'dbutil.php';


function compressEncoding64($num)
{
	$MapData = array(
			'0' , '1' , '2' , '3' , '4' , '5' ,
			'6' , '7' , '8' , '9' , 'a' , 'b' ,
			'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
			'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
			'o' , 'p' , 'q' , 'r' , 's' , 't' ,
			'u' , 'v' , 'w' , 'x' , 'y' , 'z' ,
			'A' , 'B' , 'C' , 'D' , 'E' , 'F' ,
			'G' , 'H' , 'I' , 'J' , 'K' , 'L' ,
			'M' , 'N' , 'O' , 'P' , 'Q' , 'R' ,
			'S' , 'T' , 'U' , 'V' , 'W' , 'X' ,
			'Y' , 'Z'  );
	
	
	$numk = $num;
	$resutl_s = '';
	while ($numk!=0)
	{
		$modvalue = $numk % 62;
		$resutl_s = $MapData[$modvalue] . $resutl_s ;
		$numk = (int)($numk /62);
	}
	return  $resutl_s;
}

function GenCode()
{
	$TimeMark = time();
	$Index = 1; // 001
	$StrTime =    sprintf('%s%s' ,compressEncoding64($TimeMark),compressEncoding64($Index));
	
	if (HasSameRecord($StrTime))
	{
		//echo 'find <br>';
	}
	else
	{
		//echo 'No Found;';
	}
	
	//echo $StrTime;
	return $StrTime;
}

//echo genCode();
